package com.sharer.last.controller;

import com.sharer.last.base.constant.CommonConstant;
import com.sharer.last.base.model.PageVO;
import com.sharer.last.base.model.R;
import com.sharer.last.model.dto.visitor.VisitorQueryDTO;
import com.sharer.last.model.vo.VisitorVO;
import org.springframework.web.bind.annotation.*;
import com.sharer.last.service.VisitorService;

import javax.annotation.Resource;

/**
 * 访客统计
 *
 * @ClassName VisitorAdminController
 * @Author wangjin
 * @Date 2023/5/5 21:05
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.BLOG_ADMIN_API + "/visitor")
public class VisitorAdminController {
    @Resource
    VisitorService visitorService;

    /**
     * 分页查询访客列表
     *
     * @param visitorDTO
     * @return
     */
    @PostMapping("/page")
    public R<PageVO<VisitorVO>> page(@RequestBody VisitorQueryDTO visitorDTO) {
        PageVO<VisitorVO> pageList = visitorService.selectListByPage(visitorDTO);
        return R.success(pageList);
    }

    /**
     * 按id删除访客
     *
     * @param id 访客id
     * @return
     */
    @DeleteMapping("/delete")
    public R delete(@RequestParam Long id) {
        visitorService.removeVisitorById(id);
        return R.handle();
    }
}
